#pragma once


namespace fengxi
{
	template<class Iterator,class Ref,class Ptr>
	struct ReverseIterator
	{
		typedef ReverseIterator<Iterator, Ref, Ptr> Self;

		Iterator _it;

		ReverseIterator(Iterator it)
			:_it(it)
		{}

		Ref operator*()
		{
			Iterator tmp = _it;
			return *(--tmp);
		}
		Ptr operator->()
		{
			return &(operator*());
		}

		Self operator++(int)
		{
			Iterator tmp(_it);
			++_it;
			return tmp;
		}
		Self operator--(int)
		{
			Iterator tmp(_it);
			--_it;
			return tmp;
		}
		Self operator++()
		{
			return --_it;
		}
		Self operator--()
		{
			return ++_it;
		}

		bool operator!=(const Self& r)const
		{
			return _it != r._it;
		}
		bool operator==(const Self& r)const
		{
			return _it == r._it;
		}

	};
}
